<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Error Handling Example</title>


  <script src="../../dist/monitor.js"></script>

  <script>
    monitor.init({
      url: 'http://127.0.0.1:9800/reportData',
      isImageUpload: false
    })
  </script>
</head>

<body>
  <h1>JavaScript Error Handling Example</h1>
  <img src="http://touxiao.com/x.png" alt="">
  <img src="http://touxiao.com/x2.png" alt="">
  <img src="http://touxiao.com/x3.png" alt="">


  <script>
    // 未定义变量访问
    console.log(unknownVariable)

    // 类型错误
    const num = 10
    console.log(num.toUpperCase()) // 数字没有toUpperCase方法


    // 数组越界
    const arr = [1, 2, 3]
    console.log(arr[5]) // 访问不存在的索引

    // JSON解析错误
    const jsonString = "invalid json"
    JSON.parse(jsonString)

    // 除以零
    const result = 10 / 0
    console.log(result) // 结果为Infinity，但可以用于测试边界情况

    // 函数调用错误
    function greet(name) {
      console.log(`Hello, ${name}!`)
    }
    greet() // 未传递参数

    // 异步错误
    setTimeout(() => {
      throw new Error("Error in setTimeout")
    }, 1000)

    function test() {
      return Promise.reject(new Error('Error in Promise'))
    }


  </script>
</body>

</html>